const { defineConfig } = require('@vue/cli-service')
const fs = require('fs')
const path = require('path')

module.exports = {
  devServer: {
    host: '0.0.0.0', // 允许外部访问
    port: 8080,
    https: {
      key: fs.readFileSync(path.resolve(__dirname, 'localhost-key.pem')),
      cert: fs.readFileSync(path.resolve(__dirname, 'localhost.pem'))
    },
    proxy: {
      '/api': {
        target: 'http://localhost:9090', // 后端HTTPS地址
        changeOrigin: true,
        secure: false, // 允许自签名证书
        pathRewrite: {
          '^/api': '', //这里理解成用'/api'代替target里面的地址，后面组件中我们掉接口时直接用api代替
        },
      },
    },
  },
};
